home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1996 August / Software of the Month Club 1996 August.iso / pc / os2 / filejet / install.cmd < prev    next >
OS/2 REXX Batch file  |  1996-01-28  |  6KB  |  221 lines

  1. /* FILEJET Installation                           */
  2. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  3. call SysLoadFuncs
  4. say center('┌─────────────────────────────────────┐', 79, ' ');
  5. say center('│         FILEJET Installation        │', 79, ' ');
  6. say center('│                                     │', 79, ' ');
  7. say center('└─────────────────────────────────────┘', 79, ' ');
  8. say ''
  9.  
  10. CurDir = Directory()
  11. parse SOURCE cmdd
  12. cmdd = word(cmdd,3)
  13. SrcDrv = left(cmdd, length(cmdd)-length('install.cmd')-1)
  14.  
  15. Dstdrv = 'C:'           /* default value */
  16. SeachRep = 0
  17.  
  18. SeachAgain:
  19. InnF=Srcdrv'\INSTALL.CMD'
  20.  
  21. if stream(InnF,'C','query exists') \= "" then signal FoundSrcDrv
  22.  
  23. SeachRep = SeachRep + 1
  24.  
  25. select
  26.    when SeachRep=1 then do
  27.         Srcdrv = CurDir
  28.         signal SeachAgain
  29.         end
  30.    when SeachRep=2 then do
  31.         DrvLetter = 'A'
  32.         Srcdrv = DrvLetter':\'
  33.         signal SeachAgain
  34.         end
  35.     otherwise nop
  36. end
  37.  
  38. if DrvLetter \= 'Z' then do
  39.     DrvLetter= D2C(C2D(DrvLetter)+1)
  40.     Srcdrv = DrvLetter':\'
  41.     signal SeachAgain
  42. end
  43.  
  44. Srcdrv='A:'
  45. signal NotFoundSrcDrv
  46.  
  47. FoundSrcDrv:
  48.  
  49. target_directory = 'C:\FILEJET'
  50.  
  51. signal StartInstall
  52.  
  53. /********************/
  54. /* Ask the User     */
  55. /********************/
  56.  
  57. askagain:
  58. StartInstall:
  59. RESUME:
  60. say ' Sourcedrive              :' Srcdrv
  61. say ' Target Path              :' target_directory
  62. say ''
  63. say ' Is this correct  ? (Y/N) : Y'
  64. pull answer
  65. if answer = 'N' then signal askdrives
  66.  
  67. source_drive = Srcdrv
  68. drive_info = SysDriveInfo(source_drive)
  69. parse var drive_info . . . label
  70. /* if label \= 'FILEJET' then */
  71.     do
  72.        stream_name = stream(source_drive||'\FJ2.EXE', 'c', 'query exists')
  73.        if stream_name = '' then
  74.        do
  75.           say 'Error, wrong installation disk';
  76.           exit
  77.         end
  78.     end
  79. say ''
  80. new_directory = directory(target_directory);
  81. if new_directory \= target_directory then
  82.     do
  83.        say ''
  84.        say '.. creating directory ' target_directory
  85.        rc = SysMkDir(target_directory);
  86.        if rc \= 0 then
  87.            do
  88.               if rc \= 5 then
  89.                do
  90.                 say 'Abort, error creating directory ' target_directory rc
  91.                 exit
  92.                end
  93.               else
  94.                do
  95.                 say 'Error creating directory ' target_directory
  96.                end
  97.            end
  98.        else
  99.         do
  100.           say 'Directory ' target_directory ' created';
  101.         end
  102.        new_directory = directory(target_directory);
  103.        new_directory = translate(new_directory);
  104.        target_directory = translate(target_directory);
  105.     end
  106. if new_directory = target_directory then
  107.    do
  108.        say '.. Copying FILEJET-files  to  ' target_directory '...';
  109.        '@ECHO OFF'
  110.        'COPY A:*.* ' target_directory '1>NUL 2>&1'
  111.        '@ECHO ON'
  112.    end
  113.    else do
  114.            say 'Error copying files to  ' target_directory
  115.            exit
  116.     end
  117. say '.. Creating FILEJET Objekt  '
  118. location = '<WP_DESKTOP>'
  119. title    = 'FILEJET_670'
  120. class    = 'WPProgram'
  121. progtype = 'PROGTYPE=PM;'
  122. exename  = 'EXENAME='||target_directory||'\FJ2.EXE;'
  123. workdir  = 'WORKDIR='||target_directory||';'
  124. objectid = '<FILEJET>;'
  125. open     = 'OPEN=DEFAULT;'
  126. setup    = exename||workdir||objectid||open
  127. rc = SysCreateObject(class, title, location, setup, 'R')
  128. if rc \= 1 then
  129.     do
  130.        say 'Error creating FILEJET object ';
  131.        exit
  132.     end
  133.  
  134. /********************************************************************/
  135. /* Seach for OS2 system path in PATH environement                   */
  136. /********************************************************************/
  137.  
  138. Path = value('PATH',,'OS2ENVIRONMENT')
  139. if Path = '' then signal ENDSEARCH
  140.  
  141. ntmp = pos(':\OS2;', Path)
  142. if ntmp = 0 then signal ENDSEARCH
  143.  
  144. Dstdrv=substr(Path, ntmp-1,2)
  145.  
  146. /*****************************************************************************/
  147. /*                 Checking the default values                               */
  148. /*****************************************************************************/
  149.                                                /* checking source      */
  150. if stream(Srcdrv'\FJ2.EXE', 'C', 'query exists') = "" then signal RESUME
  151.  
  152. NewDir=directory(Dstdrv'\')
  153.  
  154. InnF=Dstdrv'\CONFIG.FJ'
  155. OutF=Dstdrv'\CONFIG.SYS'
  156. stmp = 'SET FILEJET='target_directory
  157.  
  158. say '.. Copying ' OutF  ' to ' InnF
  159. '@ECHO OFF'
  160. 'copy 'OutF' 'InnF' >nul'
  161. 'del 'OutF
  162. '@ECHO ON'
  163.  
  164. found = 0
  165.  
  166. say '.. Working  ' OutF 'aktualize ' stmp
  167. do until lines(InnF) = 0
  168.     InStr = linein(InnF)
  169.     if pos('SET FILEJET=', InStr) > 0   then  do
  170.         found = 1
  171.      call lineout OutF, stmp
  172.     end
  173.     else do
  174.      call lineout OutF, InStr
  175.     end
  176. end
  177. if found = 0 then do
  178.      call lineout OutF, stmp
  179. end
  180.  
  181. call stream OutF, 'c', 'close'
  182. call stream InnF, 'c', 'close'
  183.  
  184. signal endinst
  185.  
  186. askdrives:
  187. /************/
  188. do forever
  189.    rc=CharOut(,"Enter Sourcedrive  (f.ex. A): ");
  190.    input = '';
  191.    Do While (Pos('0A'x, input)=0);
  192.       input=input||CharIn(,,1);
  193.    End;
  194.    input = c2x(input)
  195.    input = delstr(input, (length(input)-3))
  196.    input = x2c(input)
  197.    Drvletter = input
  198.    if Drvletter \= '' then leave
  199. end
  200.   Srcdrv = Drvletter':'
  201.  
  202. do forever
  203.    rc=CharOut(,"Enter the complete destination path (f.ex.: C:\FILEJET ): ");
  204.    input = '';
  205.    Do While (Pos('0A'x, input)=0);
  206.       input=input||CharIn(,,1);
  207.    End;
  208.    input = c2x(input)
  209.    input = delstr(input, (length(input)-3))
  210.    input = x2c(input)
  211.    target_directory = input
  212.    if target_directory \= '' then leave
  213. end
  214.  
  215. signal askagain
  216.  
  217.  
  218. endinst:
  219. exit
  220. 
  221.